package com.updalod.controller;

import com.updalod.service.MinIoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @program: minio
 * @description: minio
 * @author: WuChengXing
 * @create: 2020-07-16 21:05
 **/
@RestController
@Api(tags = "文件上传")
public class MinioController {

    @Autowired
    private MinIoService minioService;

    @PostMapping("/fileUpload")
    @ApiOperation(value = "默认文件夹上传")
    public String fileUpload(MultipartFile file){
        return minioService.fileUpload(file);
    }

    @PostMapping("/customizeDirUpload")
    @ApiOperation(value = "自定义文件路径文件上传格式（中央后台/头像上传）")
    public String customizeDirUpload(MultipartFile file, String dir){
        return minioService.customizeDirUpload(file, dir);
    }

    @GetMapping("/onlinePreview")
    @ApiOperation(value = "在线预览")
    public String onlinePreview(String url){
        return minioService.onlinePreview(url);
    }

}
